package timer;

import org.apache.ibatis.io.ResolverUtil;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

public class TimerTestMain {
    public static void main(String[] args) {
        Timer timer = new Timer();
//        Wed Nov 27 17:13:45 CST 2019
//        Wed Nov 27 17:13:47 CST 2019
//        Wed Nov 27 17:13:49 CST 2019
//        Wed Nov 27 17:13:51 CST 2019
//        timer.schedule(new TestTimerTask(), 1000, 1000);
//        Wed Nov 27 17:14:50 CST 2019
//        Wed Nov 27 17:14:52 CST 2019
//        Wed Nov 27 17:14:54 CST 2019
//        timer.scheduleAtFixedRate(new TestTimerTask(), 1000, 1000);

    }


    static class TestTimerTask extends TimerTask {

        @Override
        public void run() {
            System.out.println(new Date());
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
